﻿
using System.Data.Entity;
using wh40klbModel.ModelConfiguration;
using System.Data.Entity.Infrastructure;

namespace wh40klbModel
{
    public class WarhammerContext : DbContext
    {
        public DbSet<Army> Armies { get; set; }
        public DbSet<ArmySquadTypeUsed> ArmySquadTypesUsed { get; set; }
        public DbSet<Infantry> Infantries { get; set; }
        public DbSet<InfantryWargearUtilisation> InfantryWargearUtilisations { get; set; }
        public DbSet<SpecialRule> SpecialRules { get; set; }
        public DbSet<Squad> Squads { get; set; }
        public DbSet<SquadInfantryInclusion> SquadInfantryInclusions { get; set; }
        public DbSet<SquadType> SquadTypes { get; set; }
        public DbSet<SquadVehiculeInclusion> SquadVehiculeInclusions { get; set; }
        public DbSet<Transporter> Transporters { get; set; }
        public DbSet<TypeVehicule> TypeVehicules { get; set; }
        public DbSet<TypeWargear> TypeWargears { get; set; }
        public DbSet<Vehicule> Vehicules { get; set; }
        public DbSet<VehiculeWargearUtilisation> VehiculeWargearUtilisations { get; set; }
        public DbSet<Walker> Walkers { get; set; }
        public DbSet<Wargear> Wargears { get; set; }


        public WarhammerContext()
            : base("Wh40kContext")
        {

        }



        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            //modelBuilder.Entity<Army>().ToTable("Armies");

            modelBuilder.Conventions.Remove<System.Data.Entity.ModelConfiguration.Conventions.ManyToManyCascadeDeleteConvention>();
            modelBuilder.Conventions.Remove<System.Data.Entity.ModelConfiguration.Conventions.OneToManyCascadeDeleteConvention>();
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();

            modelBuilder.Configurations
                .Add(new ArmyConfiguration())
                .Add(new ArmySquadTypeUsedConfiguration())
                .Add(new InfantryConfigration())
                .Add(new InfantryWargearUtilisationConfiguration())
                .Add(new SpecialRuleConfiguration())
                .Add(new SquadConfiguration())
                .Add(new SquadInfantryInclusionConfiguration())
                .Add(new SquadTypeConfiguration())
                .Add(new SquadVehiculeInclusionConfiguration())
                .Add(new TypeVehiculeConfiguration())
                .Add(new TypeWargearConfiguration())
                .Add(new VehiculeConfiguration())
                .Add(new VehiculeWargearUtilisationConfiguration())
                .Add(new WargearConfiguration());
        }



    }
}
